<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
	String path = request.getContextPath();
//用户登陆
    String patient_id = (String)request.getParameter("patient_id") + "";; 
if(patient_id == null) {
	patient_id = "";
}
System.out.println("1----------" + patient_id);
// patient_id = "110105195305233813";
%>
<html>
	<head>
		<title>index.jsp</title>
		<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/btn_class.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/extjs/style.css" />
<script type="text/javascript"
	src="<%=path%>/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=path%>/extjs/ext-all.js"></script>


<script type="text/javascript" src = "<%=path%>/FusionCharts/FusionCharts.js"></script>
	<script type="text/javascript" src = "<%=path%>/FusionCharts/FusionChartsExportComponent.js"></script>
	<script type="text/javascript" src="<%=path%>/js/datepicker/WdatePicker.js" defer="defer"></script>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<style type="text/css">
	.sys_home {
        background-image:url(<%=path%>/extjs/icons/house.png);
    }
	.app_qygl {
        background-image:url(<%=path%>/images/Add.png);
    }
    .app_jcxx {
        background-image:url(<%=path%>/images/Comment.png);
    }
    .app_jbgl {
        background-image:url(<%=path%>/images/LineChart.png);
    }
    .app_tjfx {
        background-image:url(<%=path%>/images/PieChart.png);
    }
    .app_jcwh {
        background-image:url(<%=path%>/images/Save.png);
    }
    
    .app_exit {
        background-image:url(<%=path%>/images/Exit.png);
    }
    
    </style>
</head>

<body >
<script type="text/javascript">
Ext.onReady(function(){
	var patient_id = "<%=patient_id%>";
	
	function client_loadNewPanel(nodeid, nodename, url, folder) {
	    
		var n = client_center.getComponent(nodeid);
		if (!n) {// 如果没有打开选项卡，打开
			client_center.add(new Ext.Panel(
					{
						id : nodeid,// 设置id
						title : nodename,
						//iconCls : iconcls,
						html : '<html><head></head><body><iframe name="ifr_table" id="ifr_table" scrolling="auto" frameborder="0" width="100%" height="100%" '
								+ 'src="' + folder + '/'
								+ url.replace('\/*', '')
								+ '"></iframe></body></html>',
						closable : true
					})).show();
		} else {// 否则显示该选项卡
			n.show();
		}
	}
	
	var btn_send_mess = new Ext.Button({
					text : '发送短信',
					iconCls : 'sy-send-info',
					handler : function() {
							Ext.Ajax.request( {
								url : 'mess!sendMessClient.do',
								params:{
				    	        	'fpid' : patient_id,
				    	        	'fcontent' : Ext.get('fcontent_id').dom.value
					    	    },
								success : function() {
									Ext.MessageBox.alert(
													'提示',
													'发送成功！');
								},
								failure : function() {
									Ext.Msg.show( {
										title : '错误提示',
										msg : '发送失败！！',
										buttons : Ext.Msg.OK,
										icon : Ext.Msg.ERROR
									});
								}
							});
					}
				});
				
				var btn_mess_temp = new Ext.Button({
					text : '短信模板',
					iconCls : 'sy-email_link',
					handler : function() {
					
					
					}
				});
				
	var detailsPanel = {
					id: 'details-panel',
			        region: 'center',
					autoScroll: true,
					height : 400,
					bodyStyle: 'padding-bottom:80px;background:#FFFFFF;',
					html : '<table align="crnter">'
			 		+ '<tr> <td></td> <td align="center" id="chart_xyj_div1"></td> <td></td> </tr>'
			 		+ '<tr> <td height="30"></td> <td></td> <td></td> </tr>'
			 		+ '<tr> <td></td> <td align="center" id="chart_xty_div0"></td> <td></td> </tr>'
			 		+ '<tr> <td height="30"></td> <td></td> <td></td> </tr>'
			 		+ '<tr> <td></td> <td align="center" id="chart_xty_div1"></td> <td></td> </tr>'
			 		+ '<tr> <td height="30"></td> <td></td> <td></td> </tr>'
			 		+ '<tr> <td></td> <td align="center" id="chart_xty_div2"></td> <td></td> </tr>'
					+ '</table>'
			    };
	
	
	Ext.ux.TabCloseMenu = function(){
	    var tabs, menu, ctxItem;
	    this.init = function(tp){
	        tabs = tp;
	        tabs.on('contextmenu', onContextMenu);
	    }

	    function onContextMenu(ts, item, e){
	        if(!menu){ // create context menu on first right click
	            menu = new Ext.menu.Menu([{
	                id: tabs.id + '-close',
	                text: '关闭当前窗口',
	                handler : function(){
	                    tabs.remove(ctxItem);
	                }
	            },{
	                id: tabs.id + '-close-others',
	                text: '关闭其他窗口',
	                handler : function(){
	                    tabs.items.each(function(item){
	                        if(item.closable && item != ctxItem){
	                            tabs.remove(item);
	                        }
	                    });
	                }
	            },{
	                id: tabs.id + '-close-all',
	                text: '关闭所有窗口',
	                handler : function(){
	                    tabs.items.each(function(item){
	                        if(item.closable){
	                            tabs.remove(item);
	                        }
	                    });
	                }
	            }]);
	        }
	        ctxItem = item;
	        var items = menu.items;
	        items.get(tabs.id + '-close').setDisabled(!item.closable);
	        var disableOthers = true;
	        tabs.items.each(function(){
	            if(this != item && this.closable){
	                disableOthers = false;
	                return false;
	            }
	        });
	        items.get(tabs.id + '-close-others').setDisabled(disableOthers);
	        menu.showAt(e.getPoint());
	    }
	};
	
	var client_center = new Ext.TabPanel({
				activeTab : 0,
				border:false,
				plugins: new Ext.ux.TabCloseMenu(),
			    enableTabScroll:true,
				items : [{
				title : '首页',
				id : '0',
				iconCls : 'sys_home',
				tbar : ['快发信息：',
						    {
						xtype : 'textarea',
						id : 'fcontent_id',
						name : 'fcontent',
						style:"cursor:pointer;color:blue;",
						height : 60,
						width : 500
					}, '-', btn_send_mess , '-', btn_mess_temp],
				items: [ detailsPanel ],
				closable : false
			}]
				});
	
	/**************
	*             *
	* 监测信息按钮群 *
	*             *
	**************/			
	var menu_jcxx = new Ext.menu.Menu();
    menu_jcxx.add({
        text: '血压监测',
           handler: function(){
           client_loadNewPanel("client_xyjc_id", "血压监测", "201_xyjc.jsp", "mould_published");
       }
    });
    menu_jcxx.add({
        text: '血糖监测',
           handler: function(){
           client_loadNewPanel("client_xtjc_id", "血糖监测", "202_xtjc.jsp", "mould_published");
       }
    });
    menu_jcxx.add({
        text: '血脂监测',
           handler: function(){
           client_loadNewPanel("client_xzjc_id", "血脂监测", "buginfo.jsp", "mould_published");
       }
    });
    menu_jcxx.add({
        text: '血尿酸监测',
           handler: function(){
           client_loadNewPanel("client_xns_id", "血尿酸监测", "buginfo.jsp", "mould_published");
       }
    });
    menu_jcxx.add({
        text: '血肌酐监测',
           handler: function(){
           client_loadNewPanel("client_xjg_id", "血肌酐监测", "buginfo.jsp", "mould_published");
       }
    });
    menu_jcxx.add({
        text: 'BMI体质指数监测',
           handler: function(){
           client_loadNewPanel("client_BMI_id", "BMI体质指数监测", "buginfo.jsp", "mould_published");
       }
    });
    menu_jcxx.add({
        text: '血氧饱和度监测',
           handler: function(){
           client_loadNewPanel("client_xybhd_id", "血氧饱和度监测", "buginfo.jsp", "mould_published");
       }
    });
    menu_jcxx.add({
        text: '心电监测',
           handler: function(){
           client_loadNewPanel("client_xdjc_id", "心电监测", "buginfo.jsp", "mould_published");
       }
    });
    
    /**************
	*             *
	* 统计分析---接收信息统计分析按钮群 *
	*             *
	**************/			
	var menu_jsxxtjfx = new Ext.menu.Menu();
    menu_jsxxtjfx.add({
        text: '血压监测信息统计分析',
           handler: function(){
           client_loadNewPanel("client_xyjcxxfx_id", "血压监测信息统计分析", "421_dyhzfx.jsp", "mould_published");
       }
    });
    menu_jsxxtjfx.add({
        text: '血糖监测信息统计分析',
           handler: function(){
           client_loadNewPanel("client_xtjcxxfx_id", "血糖监测信息统计分析", "422_qzhzfx.jsp", "mould_published");
       }
    });
    
    
    /**************
	*             *
	* 统计分析按钮群 *
	*             *
	**************/			
	var menu_tjfx = new Ext.menu.Menu();
    menu_tjfx.add({
        text: '化验检查统计分析',
           handler: function(){
           client_loadNewPanel("client_hyjc_id", "化验检查统计分析", "buginfo.jsp", "mould_published");
       }
    });
    menu_tjfx.add({
        text: '门诊用药统计分析',
           handler: function(){
           client_loadNewPanel("client_mzyy_id", "门诊用药统计分析", "buginfo.jsp", "mould_published");
       }
    });
    menu_tjfx.add({
        text: '接收信息统计分析',
        menu: menu_jsxxtjfx
    });
    menu_tjfx.add({
        text: '发送信息统计分析',
           handler: function(){
           client_loadNewPanel("client_fsxxfx_id", "发送信息统计分析", "buginfo.jsp", "mould_published");
       }
    });
    menu_tjfx.add({
        text: '单一患者管理分析',
           handler: function(){
           client_loadNewPanel("client_dyhzfx_id", "单一患者管理分析", "buginfo.jsp", "mould_published");
       }
    });
    menu_tjfx.add({
        text: '群组患者管理分析',
           handler: function(){
           client_loadNewPanel("client_qzhzfx_id", "群组患者管理分析", "buginfo.jsp", "mould_published");
       }
    });
    menu_tjfx.add({
        text: '患者用药分析',
           handler: function(){
           client_loadNewPanel("client_hzyyfx_id", "患者用药分析", "buginfo.jsp", "mould_published");
       }
    });
    
    
    /**************
	*             *
	* 基础维护按钮群 *
	*             *
	**************/			
	var menu_jcwh = new Ext.menu.Menu();
    menu_jcwh.add({
        text: '提醒告知基础设置',
           handler: function(){
           client_loadNewPanel("client_txgz_id", "提醒告知基础设置", "buginfo.jsp", "mould_published");
       }
    });
    menu_jcwh.add({
        text: '家庭成员信息维护',
           handler: function(){
           client_loadNewPanel("client_jtcy_id", "家庭成员信息维护", "buginfo.jsp", "mould_published");
       }
    });
    
	
	var client_panel = new Ext.Panel({
        region: "center",
		layout:'fit',
		margins:'0 5 0 0',
        // autoScroll : true,
		tbar: [ {
                    xtype: 'buttongroup',
                   // title: 'User options',
                    autoWidth: true,
                    columns: 5,
                    defaults: {
                        xtype: 'button',
                        scale: 'large',
                        width: '100%',
                        iconAlign: 'left'
                    },
                    items: [{
                        text: '签约管理<br/>',
                        iconCls: 'app_qygl',
                        handler: function(){
				            client_loadNewPanel("client_qygl_id", "签约管理", "101_qygl.jsp", "mould_published");
				        }
                    }, {
                        iconCls: 'app_jcxx',
                        text: '监测信息<br/>',
                        menu: menu_jcxx
                    }, {
                        iconCls: 'app_jbgl',
                        text: '疾病管理<br/>',
                        handler: function(){
				            client_loadNewPanel("client_jbgl_id", "疾病管理", "301_jbgl.jsp", "mould_published");
				        }
                    }, {
                        iconCls: 'app_tjfx',
                        text: '统计分析<br/>',
                        menu: menu_tjfx
                    }, {
                        iconCls: 'app_jcwh',
                        text: '基础维护<br/>',
                        menu: menu_jcwh
                    } ]
                }, '->',{
                    xtype: 'buttongroup',
                    autoWidth: true,
                    columns: 2,
                    defaults: {
                        xtype: 'button',
                        scale: 'large',
                        width: '100%',
                        iconAlign: 'left'
                    },
                    items: [ {
                        iconCls: 'app_exit',
                        text: '退出系统<br/>',
                        handler : function() {
							if(confirm('确认退出吗?')) window.close();
						}
                    }]
                }],
        items: [
           client_center
        ]
    });
    
 	new Ext.Viewport( {
		layout : "border",
		items : [client_panel]
	});
	
	
	
	
	//血压曲线图
	Ext.Ajax.request({     
		url : 'xyj!produceXyjToChartClient.do',     
		method : 'POST',     
		params : {        
			'fpid' : patient_id,        
			'fbtime' : '', 
			'fetime' : new Date().format('Y-m-d') 
			},     
		success : function(response, action) {        
			var myChart;        
			var responseText = response.responseText; 
			var pattern = new RegExp("^[\\s]+","gi");
    					var chart_data = responseText.replace(pattern,"");
			var myChart = new FusionCharts("FusionCharts/MSLine.swf", "myChartId1", "800", "350", "0", "1");
			myChart.setDataXML(chart_data);
			myChart.render("chart_xyj_div1");
		},     
		failure : function() {        
			Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');     
		}  
	}); 
					
	Ext.Ajax.request({     
			url : 'xty!produceXtndToChartClient.do',     
			method : 'POST',     
			params : {        
				'fpid' : patient_id,        
				'fflag' : '0',//空腹血糖
				'fbtime' : '', 
				'fetime' : new Date().format('Y-m-d')  
				},     
			success : function(response, action) {        
				var myChart;        
				var responseText = response.responseText; 
				var pattern = new RegExp("^[\\s]+","gi");
     					var chart_data = responseText.replace(pattern,"");
				var myChart = new FusionCharts("FusionCharts/MSLine.swf", "myChartId1", "800", "300", "0", "1");
				myChart.setDataXML(chart_data);
				myChart.render("chart_xty_div0");
			},     
			failure : function() {        
				Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');     
			}  
		});  
					
		Ext.Ajax.request({     
			url : 'xty!produceXtndToChartClient.do',     
			method : 'POST',     
			params : {        
				'fpid' : patient_id,        
				'fflag' : '1', //餐后一小时血糖
				'fbtime' : '', 
				'fetime' : new Date().format('Y-m-d')
				},     
			success : function(response, action) {        
				var myChart;        
				var responseText = response.responseText; 
				var pattern = new RegExp("^[\\s]+","gi");
     					var chart_data = responseText.replace(pattern,"");
				var myChart = new FusionCharts("FusionCharts/MSLine.swf", "myChartId1", "800", "300", "0", "1");
				myChart.setDataXML(chart_data);
				myChart.render("chart_xty_div1");
			},     
			failure : function() {        
				Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');     
			}  
		});  
					
		Ext.Ajax.request({     
			url : 'xty!produceXtndToChartClient.do',     
			method : 'POST',     
			params : {        
				'fpid' : patient_id,        
				'fflag' : '2', //餐后两小时血糖
				'fbtime' : '', 
				'fetime' : new Date().format('Y-m-d')  
				},     
			success : function(response, action) {        
				var myChart;        
				var responseText = response.responseText; 
				var pattern = new RegExp("^[\\s]+","gi");
     					var chart_data = responseText.replace(pattern,"");
				var myChart = new FusionCharts("FusionCharts/MSLine.swf", "myChartId1", "800", "300", "0", "1");
				myChart.setDataXML(chart_data);
				myChart.render("chart_xty_div2");
			},     
			failure : function() {        
				Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');     
			}  
		}); 				
					
					
					
});
</script>

</body>
</html>
